﻿/************************************************************************
 * SMLib - State Model Library
 * Copyright (C) 2012-2013 Ali Khalili (khalili_DOT_ir_@SIGN_gmail_DOT_com)
 * **********************************************************************
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License (LGPL) published 
 * by the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version. This program is distributed without any
 * warranty. See the GNU Lesser General Public License for more details. 
 * ***********************************************************************
 * File         :     SMLib\DataTypes\EnMap.cs
 * Description  :      A clonable list
 * Change log   :     -2011: First version (originally, it was part of SimGine library)
 * To Do        :     complete the code
 ************************************************************************/
using System;
using System.Collections.Generic;

namespace SMLib.DataTypes
{

    ///// <summary>
    ///// A Stack
    ///// </summary>
    ///// <typeparam name="T"></typeparam>
    //public class EnMap<T> : IState
    ////where T : ICloneable
    //{
    //    List<T> theStack;
    //    /// <summary>
    //    /// 
    //    /// </summary>
    //    public EnMap(int maximumSize = int.MaxValue)
    //    {
    //        theStack = new List<T>();
    //    }

    //    public void Push(T value)
    //    {
    //        theStack.Add(value);
    //    }

    //    public int Count
    //    {
    //        get
    //        {
    //            return theStack.Count;
    //        }
    //    }

    //    public T Head
    //    {
    //        get
    //        {
    //            if (theStack.Count == 0)
    //                throw new Exception("Empty Stack!");
    //            return theStack[theStack.Count - 1];
    //        }
    //    }
    //    public void Clear()
    //    {
    //        theStack.Clear();
    //    }

    //    public T Pop()
    //    {
    //        T t = theStack[Count - 1];
    //        theStack.RemoveAt(Count - 1);
    //        return t;
    //    }

    //    public override string ToString()
    //    {
    //        return theStack.Count.ToString();
    //    }

    //    public override bool Equals(object obj)
    //    {
    //        if (this.GetType() != obj.GetType())
    //            return false;
    //        EnStack<T> secondobj = obj as EnStack<T>;
    //        if (this.theStack.Count != secondobj.theStack.Count)
    //            return false;
    //        for (int i = 0; i < theStack.Count; i++)
    //        {
    //            if (!theStack[i].Equals(secondobj.theStack[i]))
    //                return false;
    //        }
    //        return true;
    //    }

    //    public override int GetHashCode()
    //    {
    //        //To Do:[implement this function]
    //        return base.GetHashCode();
    //    }
    //    //Check it!
    //    public object Clone()
    //    {
    //        EnStack<T> obj = new EnStack<T>();
    //        if ((typeof(T)).IsPrimitive)
    //        {
    //            foreach (object o in theStack)
    //                obj.theStack.Add((T)((o as IState).Clone()));
    //        }
    //        else
    //        {
    //            foreach (T o in theStack)
    //                obj.theStack.Add(o);
    //        }
    //        return obj;
    //    }
    //}

}